package com.zhaopin.file;

import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) throws IOException, ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchFieldException {


        /*List<String> list1 = FileUtils.readLines(new File("dir/file/jd_all"), Charset.defaultCharset());
        List<String> list2 = FileUtils.readLines(new File("dir/file/jd_del"), Charset.defaultCharset());
        List<String> collect = list1.stream().filter(t -> !list2.contains(t)).collect(Collectors.toList());

        FileUtils.writeLines(new File("dir/file/sub_info1"),collect);
        for (int i = collect.size() - 1; i >= 0; i--) {
            System.out.println(collect.get(i));
        }*/


        List<String> list = new ArrayList<>();

        List<String> list1 = FileUtils.readLines(new File("dir/file/feature.yaml"), Charset.defaultCharset());
        for (String s : list1) {
            if (!s.startsWith(" ") && s.length() > 0){
                s = s.substring(0, s.indexOf(":"));
                for (String s1 : s.split("&")) {
                    list.add(s1);
                }
            }

        }
        for (String s : list) {
            System.out.println(s);
        }
        Collections.sort(list);

        FileUtils.writeLines(new File("dir/file/sorted_features.csv"),list);


    }
}
